import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/discover",
    name: "discover",
    redirect: "/discover/playlist",
    component: () => import("../pages/discover/index.vue"),
    children: [
      {
        path: "playlist",
        component: () => import("../pages/discover/playlist/playlist.vue"),
      },
      {
        path: "toplist",
        component: () => import("../pages/discover/toplist/toplist.vue"),
      },
    ],
  },
  {
    path: "/friend",
    name: "friend",
    component: () => import("../pages/friend/index.vue"),
  },
  {
    path: "/mine",
    name: "mine",
    component: () => import("../pages/mine/index.vue"),
  },
  {
    path: "/list",
    name: "list",
    component: () => import("../pages/list/index.vue"),
  },
  {
    path: "/list-2",
    name: "list-2",
    component: () => import("../pages/list-2/index.vue"),
  },
  {
    path: "/detail/:productid",
    name: "detail",
    component: () => import("../pages/detail/index.vue"),
  },
  {
    //动态参数解耦合
    props: true,
    path: "/detail-2/:productid",
    name: "deatil-2",
    component: () => import("../pages/detail-2/index.vue"),
  },
  {
    path: "*",
    name: "page404",
    component: () => import("../pages/page404/index.vue"),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
